package com.cy.pj.sys.commom.Util分页查询的工具类;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class ServletUtil {
//通过请求中的属性获取请求对像
    public static HttpServletRequest getRequest(){
        ServletRequestAttributes requestAttributes=
                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return requestAttributes.getRequest();
    }

    //RequestContextHolder--绑定在线程上面的请求对象，用来获取请求属性，有了属性就可以做别的事了
    public static ServletRequestAttributes getRequestAttributes(){
        return (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    }
}
